import java.util.*;

/**
 * @author LKQ
 * @date 2022/5/3 15:08
 * @description
 */
public class Solution {
    public static void main(String[] args) {

    }
    public int flipgame(int[] fronts, int[] backs) {
        Set<Integer> same = new HashSet();
        for (int i = 0; i < fronts.length; ++i) {
            if (fronts[i] == backs[i]) {
                // 正反面相同，那么不管如何翻转，该位置反面数字都在正面中
                same.add(fronts[i]);
            }
        }

        int ans = Integer.MAX_VALUE;
        for (int x: fronts) {
            if (!same.contains(x)) {
                ans = Math.min(ans, x);
            }
        }

        for (int x: backs) {
            if (!same.contains(x)) {
                ans = Math.min(ans, x);
            }
        }

        return ans == Integer.MAX_VALUE ? 0 : ans;
    }
}
